package com.qf.springmvc02.util;

import com.alibaba.fastjson.serializer.JSONSerializer;
import com.alibaba.fastjson.serializer.ObjectSerializer;

import java.io.IOException;
import java.lang.reflect.Type;

/**
 * @authorDXT
 * @date2022/5/5 10:27
 * 自定义的工资序列化器
 */
public class SalarySerializer implements ObjectSerializer {
    @Override
    public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
        // object 就是需要序列化的属性的值  fieldName：需要序列化的属性的名字 fieldType：属性的类型
        Double salary = (Double) object;
        // 输出序列化后的值
        serializer.write(salary+"元");
    }
}
